package web.weibo.service;

import org.springframework.stereotype.Component;
import web.weibo.mapper.MapperMessage;
import web.weibo.model.*;
import java.util.ArrayList;

@Component
public class ServiceMessage {

    private MapperMessage mapperMessage;

    ServiceMessage(MapperMessage mapperMessage) {
        this.mapperMessage = mapperMessage;
    }

    /**
     * 获取当前 userId 的数据
     *
     * @param currentUser
     * @return
     */
    public ArrayList<Message> currentUserMessages(User currentUser) {
        ArrayList<Message> messages = this.mapperMessage.messages(currentUser.id);
        return messages;
    }

    public void addGet(String content, User currentUser) {
        this.mapperMessage.messagesGet(currentUser.id, content);
    }

    public void addPost(String content, User currentUser) {
        this.mapperMessage.messagesPost(currentUser.id, content);
    }
}
